package cn.tedu.hhmc.patient_service_item_relation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.tedu.hhmc.base.response.JsonResult;
import cn.tedu.hhmc.patient_service_item_relation.pojo.entity.PatientServiceItemRelation;
import cn.tedu.hhmc.patient_service_item_relation.service.IPatientServiceItemRelationService;
import cn.tedu.hhmc.patient_service_item_relation.pojo.vo.PatientServiceItemRelationVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 病人-服务项目关联Controller
 * 
 * @author ruoyi
 * @date 2024-12-05
 */
@Slf4j
@RestController
@RequestMapping("/hhmc/patientItemRelation")
public class PatientServiceItemRelationController
{
    @Autowired
    private IPatientServiceItemRelationService patientServiceItemRelationService;

    /**
     * 查询所有病人-服务项目关联列表
     */
    @GetMapping("/list")
    public JsonResult list()
    {
        log.debug("查询所有病人-服务项目关联信息列表,参数:无");
        List<PatientServiceItemRelationVO> list = patientServiceItemRelationService.selectPatientServiceItemRelationList(new PatientServiceItemRelation());
        return JsonResult.ok(list);
    }

    /**
     * 查询病人-服务项目关联列表
     */
    @GetMapping("/select")
    public JsonResult select(PatientServiceItemRelation patientServiceItemRelation)
    {
        List<PatientServiceItemRelationVO> list = patientServiceItemRelationService.selectPatientServiceItemRelationList(patientServiceItemRelation);
        return JsonResult.ok(list);
    }

    /**
     * 导出病人-服务项目关联列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, PatientServiceItemRelation patientServiceItemRelation)
    {
        List<PatientServiceItemRelationVO> list = patientServiceItemRelationService.selectPatientServiceItemRelationList(patientServiceItemRelation);
//        ExcelUtil<PatientServiceItemRelation> util = new ExcelUtil<PatientServiceItemRelation>(PatientServiceItemRelation.class);
//        util.exportExcel(response, list, "病人-服务项目关联数据");
    }

    /**
     * 获取病人-服务项目关联详细信息
     */
    @GetMapping(value = "/{patientId}")
    public JsonResult getInfo(@PathVariable("patientId") Long patientId)
    {
        return JsonResult.ok(patientServiceItemRelationService.selectPatientServiceItemRelationByPatientId(patientId));
    }

    /**
     * 新增病人-服务项目关联
     */
    @PostMapping
    public JsonResult add(@RequestBody PatientServiceItemRelation patientServiceItemRelation)
    {
        patientServiceItemRelationService.insertPatientServiceItemRelation(patientServiceItemRelation);
        return JsonResult.ok();
    }

    /**
     * 修改病人-服务项目关联
     */
    @PutMapping
    public JsonResult edit(@RequestBody PatientServiceItemRelation patientServiceItemRelation)
    {
        patientServiceItemRelationService.updatePatientServiceItemRelation(patientServiceItemRelation);
        return JsonResult.ok();
    }

    /**
     * 删除病人-服务项目关联
     */
	@DeleteMapping("/{patientIds}")
    public JsonResult remove(@PathVariable Long[] patientIds)
    {
        patientServiceItemRelationService.deletePatientServiceItemRelationByPatientIds(patientIds);
        return JsonResult.ok();
    }
}
